class FeedbackRecordModel {
  final String? id;
  final String? feedbackInfoId;
  final String? workOrderType;
  final String? workOrderTypeName;
  final String? title;
  final String? content;
  final String? createTime;
  final String? status;
  final String? statusDesc;

  const FeedbackRecordModel({
    this.id,
    this.feedbackInfoId,
    this.workOrderType,
    this.workOrderTypeName,
    this.title,
    this.content,
    this.createTime,
    this.status,
    this.statusDesc,
  });

  factory FeedbackRecordModel.fromJson(Map<String, dynamic> json) {
    return FeedbackRecordModel(
      id: json['id']?.toString(),
      feedbackInfoId: json['feedbackInfoId']?.toString(),
      workOrderType: json['workOrderType'] as String?,
      workOrderTypeName: json['workOrderTypeDisplayName'] as String? ??
          json['workOrderTypeName'] as String?,
      title: json['title'] as String?,
      content: json['content'] as String? ?? json['description'] as String?,
      createTime: json['createTime'] as String? ??
          json['createDt'] as String? ??
          json['createdAt'] as String?,
      status: json['status']?.toString(),
      statusDesc: json['statusDesc'] as String? ??
          json['statusName'] as String? ??
          json['statusText'] as String?,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'feedbackInfoId': feedbackInfoId,
      'workOrderType': workOrderType,
      'workOrderTypeName': workOrderTypeName,
      'title': title,
      'content': content,
      'createTime': createTime,
      'status': status,
      'statusDesc': statusDesc,
    };
  }

  String get displayTitle {
    if (title != null && title!.isNotEmpty) {
      return title!;
    }
    if (workOrderTypeName != null && workOrderTypeName!.isNotEmpty) {
      return workOrderTypeName!;
    }
    if (workOrderType != null && workOrderType!.isNotEmpty) {
      return workOrderType!;
    }
    return '反馈';
  }

  String get displayStatus {
    if (statusDesc != null && statusDesc!.isNotEmpty) {
      return statusDesc!;
    }
    if (status != null && status!.isNotEmpty) {
      return status!;
    }
    return '';
  }

  String get statusStr {
    final trimmedStatus = status?.trim();
    switch (trimmedStatus) {
      case '0':
        return '待处理';
      case '1':
        return '已处理';
      case '2':
        return '已关闭';
      default:
        return displayStatus;
    }
  }

  String get displayContent {
    if (content != null && content!.isNotEmpty) {
      return content!;
    }
    return '';
  }
}
